import TaroRouter from '@doctorwork/utils/router';

const subPackages = [
    '_login',
    'login',
    'web',
    'signIn',
    'address',
    'address-edit'
];

const subPackagesReg = new RegExp(
    'pages/(' + subPackages.join('|') + ')/index'
);

const router = new TaroRouter({ subPackagesReg });

export default {
    namespace: '$router',
    state: {},
    effects: {
        *switchTab({ payload }) {
            router.switchTab(payload);
        },
        // push
        *forward({ payload }) {
            router.forward(payload);
        },
        //pop
        *back({ payload }) {
            console.log('准备路由跳转');
            router.back(payload);
        },
        *redirect({ payload }) {
            router.redirect(payload);
        }
    }
};
